package com.itheima.d11_observer2;

/**
 * 目标：了解观察者设计模式
 */
public class Test {

    public static void main(String[] args) {
        //1.创建三个客户
        Person smallRainBrother = new Person("小雨哥", 28);
        Person tinyintRainBrother = new Person("微小雨哥", 18);
        Person bigRainBrother = new Person("大雨哥", 48);


        //2.创建一个房子
        Home home = new Home(20000);

        //3.订阅/关注此房价
        home.addObserver(smallRainBrother);
        home.addObserver(tinyintRainBrother);
        home.addObserver(bigRainBrother);

        System.out.println("一个月后，降价，5000");
        home.setPrice(home.getPrice() - 5000);

        System.out.println();

        System.out.println("一个月后，小雨哥给主播刷礼物，没钱了，不关注");
        home.deleteObserver(smallRainBrother);

        System.out.println("三个月后，降价，3000");
        home.setPrice(home.getPrice() - 3000);


    }
}
